package com.link2room.aeriabots.thread.task;

import com.link2room.aeriabots.thread.TaskResult;
import com.link2room.common.service.ICommonService;
import com.link2room.common.util.SpringUtil;
import com.link2room.aeriabots.entity.WxMemberInfo;

import java.util.concurrent.Callable;

/**
 * Created by LN on 2016/11/18.
 */
public class SaveWxMemberInfoTask implements Callable<TaskResult> {
    private WxMemberInfo memberInfo;
    private ICommonService commonService;
    public SaveWxMemberInfoTask(WxMemberInfo memberInfo){
        this.memberInfo = memberInfo;
        commonService =  (ICommonService) SpringUtil.getBean("commonServiceSupport");
    }
    @Override
    public TaskResult call() throws Exception {
        TaskResult result = new TaskResult();
        try{
            commonService.save(memberInfo);
        }catch (Exception e){
            result.setResultCode(TaskResult.ERROR);
            result.setResultMessage("Task had Exception:"+e.getMessage());
            result.setException(e);
            throw e;
        }finally {
            return result;
        }
    }
}
